package com.cloud.base.proxy;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

@Slf4j
public class MayiktCglibMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        log.info("<目标方法之前开始执行....>");
//        Object result = method.invoke(obj, args);
        Object result = proxy.invokeSuper(obj, args);
        log.info("<目标方法之后开始执行....>");
        return result;
    }
}